package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

/**
 * @author DBX
 * @effect 集合间的操作
 * @date 2021/09/03/9:28
 */
public class CollectionDemo4 {
    public static void main(String[] args) {
        Collection c1 = new ArrayList();
        c1.add("我");
        c1.add("是");
        c1.add("你");
        Collection c2 = new HashSet();
        c2.add("爹");
        c2.add("你");

        c2.addAll(c1);
        System.out.println(c2);

        boolean contains = c2.containsAll(c1);//真包含
        System.out.println("包含所有元素："+contains);

        System.out.println(c1);
        System.out.println(c2);

        c2.removeAll(c1);//删除当前集合中与给定集合的共有元素，给定集合不受影响
        System.out.println(c1);
        System.out.println(c2);
    }
}
